#define _CRT_SECURE_NO_WARNINGS
#include "3.6_hs.h"
void Print_int_arr(int* p, size_t width)
{
	for (int i = 0; i < width;)
		printf("%-2d ", p[i++]);
	printf("%c", 10);
}

int cmp_name(const void* e1, const void* e2)
{
	return strcmp(((struct emp*)e2)->name, ((struct emp*)e1)->name);
}

void Swap(char* e1, char* e2,size_t width)
{
	for (int i = 0; i < width; i++)
	{
		char t = e1[i];
		e1[i] = e2[i];
		e2[i] = t;
	}
}

void my_qsort(void* base, size_t num, size_t size, int(*compare)(const void*, const void*))
{
	for (int n = 0; n < num - 1; n++)
	{
		int flag = 1;
		for (int j = 0; j < num - 1 - n; j++)
		{
			if (compare((char*)base + j * size, (char*)base + (j + 1) * size) > 0)
			{
				Swap((char*)base + j * size, (char*)base + (j + 1) * size, size);
				flag = 0;
			}
		}
		if (flag == 1)
			break;
	}
}

int add(int x, int y)
{
	return x + y;
}

int mul(int x, int y)
{
	return x * y;
}
